package gui.utils;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

/*Author: John Archer, Contact: john.archer.jpa@gmail.com*/
public class CheckBox extends JPanel implements ActionListener{
    public static int UPDATEREF = 1;
    private JRadioButton button;
    private int which;
    public CheckBox(String title, int which, boolean initialVal){
        super(new BorderLayout());
        this.which = which;
        JLabel modelLabel = new JLabel(title);
        modelLabel.setFont(Borders.getFont(Borders.GUIFONT));
        modelLabel.setBorder(BorderFactory.createEmptyBorder(3,3,3,3));
        this.add(modelLabel, BorderLayout.WEST);
        button = new JRadioButton();
        button.setSelected(initialVal);
        button.setBorder(BorderFactory.createEmptyBorder(3,3,3,12));
        button.addActionListener(this);
        this.add(button, BorderLayout.EAST);
    }

    public void actionPerformed(ActionEvent ae){
        if(which==UPDATEREF){
            if(button.isSelected()){Para.UPDATEREF = true;}
            else{Para.UPDATEREF = false;}
        }
        
    }
}
